<table>
	<tr>
		<th>Name</th>
		<th>Date/Time</th>
		<th>Duration</th>
		<th>Commander</th>
		<% if is_regd %>
		<th>Attending With</th>
		<% end %>
		<th>Type</th>
		<th>Comms</th>
		<th># Participants</th>
	    <% if not is_regd %>
		<th>Register</th>
		<% end %>
	</tr>
<% if missions.size == 0 %>
	<tr>
		<td colspan="5" align="center">No missions</td>
	</tr>
<% else %>
	<% for mission in missions %>
		<tr>
			<td><%= link_to mission.name, :controller => 'missions', :action => 'show', :id => mission %></td>
			<td><%= mission.start_date %></td>
			<td><%= mission.duration.name %></td>
			<td><%= MissionRegistration.find_by_is_leader_and_mission_id(1, mission.id).character.name  %></td>
			<% if is_regd %>
			<td><%= MissionRegistration.find_by_member_id_and_mission_id(session[:member_id], mission.id).character.name %></td>
			<% end %>
			<td><%= mission.mission_type.name %></td>
			<td><%= mission.comms_type.name %></td>
			<td><%= mission.mission_registrations.length %></td>
			<% if is_regd %>
				<% if mission.member == @member %>
					<td id="cancel_mission">
				<%= link_to "Cancel Mission", :action => 'cancel_mission', :id => mission,
					:confirm => 'Are you sure?', :post => true %>
					</td>
				<% else %>
					<td id="resign_mission">
				<%= link_to "Resign From Mission", 
				   :controller => 'mission_registrations', :action => 'destroy',
				   :id => MissionRegistration.find_by_member_id_and_mission_id(session[:member_id], mission.id) %>
					</td>
				<% end %>
			<% elsif Time.now.to_i < mission.start_date.to_i - (mission.reg_cutoff * 60) %>
				<td id="register">
				<%= link_to 'Register for Event', :controller => 'mission_registrations', 
					:action => 'new', :id => mission %>
				</td>
			<% else %>
				<td id="register">
					Past Registration Cut-off
				</td>
			<% end %> 
		</tr>
	<% end %>
<% end %>
</table>